<template>
  <div class="charge-billing-container">
    <!-- 左侧树形结构区域 -->
    <div class="left-tree-panel">
      <div class="tree-header">
        <h4>
          <i class="el-icon-office-building"></i>
          楼栋用房分类
        </h4>
      </div>
      <div class="tree-search">
        <el-input 
          v-model="treeSearchText" 
          placeholder="请输入楼栋内容" 
          size="small" 
          clearable>
          <i slot="prefix" class="el-input__icon el-icon-search"></i>
        </el-input>
      </div>
      <div class="tree-container">
        <el-tree
          :data="treeData"
          :props="treeProps"
          :filter-node-method="filterNode"
          ref="tree"
          node-key="id"
          :expand-on-click-node="false"
          :default-expand-all="true"
          :highlight-current="true"
          @node-click="handleNodeClick"
          class="custom-tree">
          <span class="custom-tree-node" slot-scope="{ node, data }">
            <span class="tree-node-label">
              <i :class="getNodeIcon(data)" class="tree-node-icon"></i>
              {{ node.label }}
            </span>
          </span>
        </el-tree>
      </div>
    </div>

    <!-- 右侧内容区域 -->
    <div class="right-content-panel">
      <div class="charge-billing">
        <!-- Tab切换 -->
        <div class="tab-container">
          <el-tabs v-model="activeTab" @tab-click="handleTabClick" class="custom-tabs">
            <el-tab-pane label="能源缴费" name="energy-billing">
              <template slot="label">
                <span class="tab-label">
                  <i class="el-icon-lightning"></i>
                  能源缴费
                </span>
              </template>
            </el-tab-pane>
            <el-tab-pane label="合并缴费" name="merged-billing">
              <template slot="label">
                <span class="tab-label">
                  <i class="el-icon-collection"></i>
                  合并缴费
                </span>
              </template>
            </el-tab-pane>
            <el-tab-pane label="物业费" name="property-fee">
              <template slot="label">
                <span class="tab-label">
                  <i class="el-icon-house"></i>
                  物业费
                </span>
              </template>
            </el-tab-pane>
          </el-tabs>
        </div>
        <!-- 搜索筛选区 -->
        <div class="filter-container">
          <el-form :inline="true" :model="filterForm" class="filter-form">
            <el-form-item label="房间信息:">
              <el-input 
                v-model="filterForm.roomInfo" 
                placeholder="请输入"
                clearable
                class="filter-input"
              ></el-input>
            </el-form-item>
            <el-form-item label="业主信息:">
              <el-input 
                v-model="filterForm.businessInfo" 
                placeholder="请输入"
                clearable
                class="filter-input"
              ></el-input>
            </el-form-item>
            <el-form-item label="电话号码:">
              <el-input 
                v-model="filterForm.phone" 
                placeholder="请输入"
                clearable
                class="filter-input"
              ></el-input>
            </el-form-item>
            <el-form-item label="是否欠费:">
              <el-select 
                v-model="filterForm.isArrears" 
                placeholder="全部"
                clearable
                class="filter-select"
              >
                <el-option label="全部" value=""></el-option>
                <el-option label="是" value="yes"></el-option>
                <el-option label="否" value="no"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="报警状态:">
              <el-select 
                v-model="filterForm.alarmStatus" 
                placeholder="全部"
                clearable
                class="filter-select"
              >
                <el-option label="全部" value=""></el-option>
                <el-option label="正常" value="normal"></el-option>
                <el-option label="报警" value="alarm"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="searchData">查询</el-button>
              <el-button icon="el-icon-refresh" @click="resetFilter">重置</el-button>
            </el-form-item>
          </el-form>
        </div>
        <!-- 操作按钮区 -->
        <div class="action-container">
          <div class="action-left">
            <div class="action-buttons">
              <el-button 
                type="success" 
                icon="el-icon-money" 
                @click="batchCharge"
                :disabled="selectedRows.length === 0"
              >
                缴费记录 ({{ selectedRows.length }})
              </el-button>
              <el-button 
                type="warning" 
                icon="el-icon-download" 
                @click="exportData"
                :disabled="selectedRows.length === 0"
              >
                导出表格 ({{ selectedRows.length }})
              </el-button>
              <el-button 
                type="info" 
                icon="el-icon-view" 
                @click="viewChargeRecord"
                :disabled="selectedRows.length === 0"
              >
                批量缴费 ({{ selectedRows.length }})
              </el-button>
              <el-button 
                type="primary" 
                icon="el-icon-check" 
                @click="confirmBilling"
                :disabled="selectedRows.length === 0"
              >
                确认订单 ({{ selectedRows.length }})
              </el-button>
              <el-button 
                type="info" 
                icon="el-icon-refresh-left" 
                @click="clearSelection"
                :disabled="selectedRows.length === 0"
                size="small"
              >
                清空选择
              </el-button>
            </div>
            <div class="selection-info">
              <span v-if="selectedNode" class="selected-node">
                当前选择: {{ selectedNode.label }}
              </span>
              <span v-if="selectedRows.length > 0" class="selected-count">
                已选择 {{ selectedRows.length }} 项
              </span>
            </div>
          </div>
        </div>
        <!-- 数据表格 -->
        <div class="table-container">
          <div class="table-header">
            <div class="table-title">
              <i class="el-icon-tickets"></i>
              缴费列表
            </div>
            <div class="table-info">
              共 {{ tableData.length }} 条数据
            </div>
          </div>
          <el-table 
            :data="tableData" 
            border
            style="width: 100%"
            :header-cell-style="headerCellStyle"
            class="custom-table"
            v-loading="loading"
            element-loading-text="加载中..."
            :row-style="{backgroundColor: '#fff'}"
            @selection-change="handleSelectionChange"
            ref="multipleTable"
          >
            <!-- 勾选框列 -->
            <el-table-column
              type="selection"
              width="55"
              align="center"
              :selectable="checkSelectable">
            </el-table-column>
            
            <el-table-column prop="id" label="序号" width="80" align="center"></el-table-column>
            <el-table-column prop="roomInfo" label="房间信息" width="150" align="center"></el-table-column>
            <el-table-column prop="businessInfo" label="业主信息" width="120" align="center"></el-table-column>
            <el-table-column prop="contactPhone" label="电话号码" width="140" align="center"></el-table-column>
            <el-table-column prop="electricMeterNumber" label="电表表号" width="100" align="center"></el-table-column>
            <el-table-column prop="waterMeterNumber" label="水表表号" width="100" align="center"></el-table-column>
            <el-table-column prop="mediaMeterNumber" label="流体表号" width="100" align="center"></el-table-column>
            <el-table-column prop="mergeBilling" label="合并计费" width="100" align="center">
              <template slot-scope="scope">
                <el-tag 
                  size="small" 
                  :type="scope.row.mergeBilling === '已合并' ? 'success' : 'warning'"
                >
                  {{ scope.row.mergeBilling }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="remainingAmount" label="余额(元)" width="100" align="center">
              <template slot-scope="scope">
                <span :class="scope.row.remainingAmount > 0 ? 'positive-amount' : 'negative-amount'">
                  {{ scope.row.remainingAmount }}
                </span>
              </template>
            </el-table-column>
            <el-table-column label="操作" width="120" fixed="right" align="center">
              <template slot-scope="scope">
                <el-button 
                  type="primary" 
                  size="mini" 
                  icon="el-icon-money"
                  @click="openChargeDialog(scope.row)"
                >
                  充值缴费
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <!-- 底部统计 -->
          <div class="table-footer">
            <div class="summary-info">
              <span class="summary-item">
                <strong>总余额: {{ totalAmount }}</strong>
              </span>
              <span class="summary-item">
                <strong>总欠费: {{ totalDebt }}</strong>
              </span>
            </div>
          </div>
        </div>
        
        <!-- 充值缴费弹窗 - 使用HTML硬编码 -->
        <div v-if="showChargeDialog" class="charge-dialog-overlay" @click="closeDialog">
          <div class="charge-dialog" @click.stop>
            <div class="dialog-header">
              <h3 class="dialog-title">充值缴费</h3>
              <button class="close-btn" @click="closeDialog">×</button>
            </div>
            
            <div class="dialog-body">
              <div class="charge-dialog-content">
                <!-- 左侧充值区域 -->
                <div class="charge-section">
                  <div class="section-header">
                    <div class="section-title">充值缴费</div>
                  </div>
                  <div class="charge-form">
                    <div class="account-balance">
                      <div class="balance-display">
                        <div class="balance-label">账户余额</div>
                        <div class="balance-amount negative-balance">
                          <span class="amount">-9950</span>
                          <span class="unit">元</span>
                        </div>
                        <div class="balance-note">预存: 9950元,补扣: 0元</div>
                      </div>
                    </div>
                    <div class="form-container">
                      <div class="form-item">
                        <label class="form-label">请输入金额:</label>
                        <input 
                          type="text" 
                          class="form-input amount-input"
                          placeholder="请输入金额"
                          v-model="chargeForm.amount"
                        />
                      </div>
                      <div class="form-item">
                        <label class="form-label">大写:</label>
                        <span class="amount-chinese">零元整</span>
                      </div>
                      <div class="form-item">
                        <label class="form-label">缴费类型:</label>
                        <div class="payment-type-group">
                          <label class="radio-item">
                            <input type="radio" name="paymentType" value="保存" checked />
                            <span class="radio-text">保存</span>
                          </label>
                          <label class="radio-item">
                            <input type="radio" name="paymentType" value="退费" />
                            <span class="radio-text">退费</span>
                          </label>
                          <label class="radio-item">
                            <input type="radio" name="paymentType" value="补助" />
                            <span class="radio-text">补助</span>
                          </label>
                        </div>
                      </div>
                      <div class="form-item">
                        <label class="form-label">备注:</label>
                        <textarea 
                          class="form-textarea"
                          placeholder="请输入"
                          rows="3"
                          v-model="chargeForm.remark"
                        ></textarea>
                      </div>
                      <div class="form-item">
                        <button 
                          class="charge-btn"
                          @click="confirmCharge"
                          :disabled="charging"
                        >
                          {{ charging ? '处理中...' : '确认保存' }}
                        </button>
                      </div>
                    </div>
                  </div>
                </div>
                <!-- 右侧缴费详情 -->
                <div class="detail-section">
                  <div class="section-header">
                    <div class="section-title">缴费详情</div>
                    <div class="detail-time">
                      次费跳闸明细时间: {{ currentTime }}
                    </div>
                  </div>
                  <div class="detail-table-container">
                    <table class="detail-table">
                      <thead>
                        <tr>
                          <th>类型</th>
                          <th>仪表表号</th>
                          <th>本月用量</th>
                          <th>上月用量</th>
                          <th>消费金额</th>
                          <th>本月金额</th>
                          <th>通讯状态</th>
                          <th>最后通讯时间</th>
                        </tr>
                      </thead>
                      <tbody>
                        <tr>
                          <td>电表</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td><span class="status-failed">失败</span></td>
                          <td></td>
                        </tr>
                        <tr>
                          <td>电表</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td><span class="status-failed">失败</span></td>
                          <td></td>
                        </tr>
                        <tr>
                          <td>电表</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td><span class="status-failed">失败</span></td>
                          <td></td>
                        </tr>
                        <tr>
                          <td>电表</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td>0</td>
                          <td><span class="status-failed">失败</span></td>
                          <td></td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
              
              <!-- 缴费记录 -->
              <div class="charge-records">
                <div class="records-header">
                  <div class="records-title">缴费记录</div>
                </div>
                <div class="records-table-container">
                  <table class="records-table">
                    <thead>
                      <tr>
                        <th>序号</th>
                        <th>缴费时间</th>
                        <th>缴费类型</th>
                        <th>清零金额</th>
                        <th>缴费来源</th>
                        <th>缴费金额 (元)</th>
                        <th>余额 (元)</th>
                        <th>操作人</th>
                        <th>是否成功</th>
                        <th>操作</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr>
                        <td>1</td>
                        <td></td>
                        <td>预存</td>
                        <td></td>
                        <td>现金</td>
                        <td>50.00</td>
                        <td>50.00</td>
                        <td></td>
                        <td><span class="success-tag">成功</span></td>
                        <td><button class="print-btn">票据打印</button></td>
                      </tr>
                      <tr>
                        <td>2</td>
                        <td></td>
                        <td>核销</td>
                        <td></td>
                        <td>现金</td>
                        <td>50.00</td>
                        <td>50.00</td>
                        <td></td>
                        <td><span class="success-tag">成功</span></td>
                        <td><button class="print-btn">票据打印</button></td>
                      </tr>
                      <tr>
                        <td>3</td>
                        <td></td>
                        <td>预存</td>
                        <td></td>
                        <td>现金</td>
                        <td>50.00</td>
                        <td>50.00</td>
                        <td></td>
                        <td><span class="success-tag">成功</span></td>
                        <td><button class="print-btn">票据打印</button></td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import chargeBillingMock from '@/api/mock/chargeBilling'

export default {
  name: 'ChargeBilling',
  data() {
    return {
      // 树形结构相关
      treeSearchText: '',
      treeData: [],
      selectedNode: null,
      treeProps: {
        children: 'children',
        label: 'label'
      },
      activeTab: 'energy-billing',
      loading: false,
      charging: false,
      tableData: [],
      selectedRows: [], // 选中的行数据
      totalAmount: 100,
      totalDebt: -9950,
      filterForm: {
        roomInfo: '',
        businessInfo: '',
        phone: '',
        isArrears: '',
        alarmStatus: ''
      },
      // 充值缴费弹窗相关
      showChargeDialog: false,
      selectedTenant: null,
      chargeForm: {
        amount: '',
        paymentType: '保存',
        remark: ''
      },
      chargeDetailData: [],
      chargeRecords: [],
      currentTime: ''
    }
  },
  computed: {
    headerCellStyle() {
      return {
        backgroundColor: '#f5f7fa',
        color: '#606266',
        fontWeight: 'bold'
      }
    }
  },
  watch: {
    treeSearchText(val) {
      this.$refs.tree.filter(val)
    }
  },
  mounted() {
    this.initData()
    this.getCurrentTime()
  },
  methods: {
    // 初始化数据
    initData() {
      this.loadTreeData()
      this.loadTableData()
    },
    
    // 获取当前时间
    getCurrentTime() {
      const now = new Date()
      this.currentTime = now.toLocaleString()
    },
    
    // 加载树形数据
    loadTreeData() {
      this.treeData = chargeBillingMock.getTreeData()
    },
    
    // 加载表格数据
    loadTableData() {
      this.loading = true
      setTimeout(() => {
        this.tableData = chargeBillingMock.getTableData()
        this.loading = false
      }, 500)
    },
    
    // 树节点点击
    handleNodeClick(data) {
      this.selectedNode = data
      console.log('选中节点:', data)
    },
    
    // 获取节点图标
    getNodeIcon(data) {
      if (data.type === 'building') {
        return 'el-icon-office-building'
      } else if (data.type === 'floor') {
        return 'el-icon-menu'
      } else if (data.type === 'room') {
        return 'el-icon-house'
      }
      return 'el-icon-folder'
    },
    
    // 树节点过滤
    filterNode(value, data) {
      if (!value) return true
      return data.label.indexOf(value) !== -1
    },
    
    // Tab切换
    handleTabClick(tab) {
      console.log('切换Tab:', tab.name)
    },
    
    // 搜索数据
    searchData() {
      console.log('搜索条件:', this.filterForm)
      this.loadTableData()
    },
    
    // 重置筛选条件
    resetFilter() {
      this.filterForm = {
        roomInfo: '',
        businessInfo: '',
        phone: '',
        isArrears: '',
        alarmStatus: ''
      }
      this.loadTableData()
    },
    
    // 表格选择变化
    handleSelectionChange(selection) {
      this.selectedRows = selection
    },
    
    // 检查行是否可选
    checkSelectable(row, index) {
      return true // 所有行都可选
    },
    
    // 批量充值
    batchCharge() {
      if (this.selectedRows.length === 0) {
        this.$message.warning('请先选择要充值的记录')
        return
      }
      console.log('批量充值:', this.selectedRows)
    },
    
    // 导出数据
    exportData() {
      if (this.selectedRows.length === 0) {
        this.$message.warning('请先选择要导出的记录')
        return
      }
      console.log('导出数据:', this.selectedRows)
    },
    
    // 查看充值记录
    viewChargeRecord() {
      if (this.selectedRows.length === 0) {
        this.$message.warning('请先选择记录')
        return
      }
      console.log('查看充值记录:', this.selectedRows)
    },
    
    // 确认账单
    confirmBilling() {
      if (this.selectedRows.length === 0) {
        this.$message.warning('请先选择要确认的记录')
        return
      }
      console.log('确认账单:', this.selectedRows)
    },
    
    // 清空选择
    clearSelection() {
      this.$refs.multipleTable.clearSelection()
    },
    
    // 打开充值弹窗
    openChargeDialog(row) {
      this.selectedTenant = row
      this.showChargeDialog = true
      this.chargeForm = {
        amount: '',
        paymentType: '保存',
        remark: ''
      }
      this.loadChargeDetailData()
      this.loadChargeRecords()
      this.getCurrentTime()
    },
    
    // 关闭弹窗
    closeDialog() {
      this.showChargeDialog = false
    },
    
    // 加载缴费详情数据
    loadChargeDetailData() {
      this.chargeDetailData = [
        { type: '电表', meterNumber: '0', lastMonth: 0, thisMonth: 0, consumption: 0, thisMonthAmount: 0, status: '失败', lastUpdateTime: '' },
        { type: '电表', meterNumber: '0', lastMonth: 0, thisMonth: 0, consumption: 0, thisMonthAmount: 0, status: '失败', lastUpdateTime: '' },
        { type: '电表', meterNumber: '0', lastMonth: 0, thisMonth: 0, consumption: 0, thisMonthAmount: 0, status: '失败', lastUpdateTime: '' },
        { type: '电表', meterNumber: '0', lastMonth: 0, thisMonth: 0, consumption: 0, thisMonthAmount: 0, status: '失败', lastUpdateTime: '' }
      ]
    },
    
    // 加载缴费记录
    loadChargeRecords() {
      this.chargeRecords = [
        { id: 1, chargeTime: '', type: '预存', clearAmount: '', source: '现金', amount: '50.00', balance: '50.00', operator: '', success: '成功' },
        { id: 2, chargeTime: '', type: '核销', clearAmount: '', source: '现金', amount: '50.00', balance: '50.00', operator: '', success: '成功' },
        { id: 3, chargeTime: '', type: '预存', clearAmount: '', source: '现金', amount: '50.00', balance: '50.00', operator: '', success: '成功' }
      ]
    },
    
    // 确认充值
    confirmCharge() {
      if (!this.chargeForm.amount) {
        this.$message.warning('请输入充值金额')
        return
      }
      
      this.charging = true
      setTimeout(() => {
        this.$message.success('充值成功')
        this.charging = false
        this.showChargeDialog = false
        this.loadTableData() // 刷新表格数据
      }, 1500)
    },
    
    // 打印记录
    printRecord(record) {
      console.log('打印记录:', record)
      this.$message.info('正在打印票据...')
    }
  }
}
</script>

<style scoped>
/* 主容器样式 */
.charge-billing-container {
  display: flex;
  height: 100vh;
  background-color: #f5f7fa;
}

/* 左侧树形面板 */
.left-tree-panel {
  width: 280px;
  background: white;
  border-right: 1px solid #e4e7ed;
  display: flex;
  flex-direction: column;
}

.tree-header {
  padding: 20px;
  border-bottom: 1px solid #e4e7ed;
}

.tree-header h4 {
  margin: 0;
  color: #303133;
  font-size: 16px;
}

.tree-search {
  padding: 15px 20px;
  border-bottom: 1px solid #e4e7ed;
}

.tree-container {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
}

/* 右侧内容面板 */
.right-content-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.charge-billing {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* Tab容器 */
.tab-container {
  margin-bottom: 20px;
}

.custom-tabs .tab-label {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 筛选容器 */
.filter-container {
  background: white;
  padding: 20px;
  border-radius: 4px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.filter-form .el-form-item {
  margin-bottom: 10px;
}

.filter-input,
.filter-select {
  width: 180px;
}

/* 操作容器 */
.action-container {
  background: white;
  padding: 15px 20px;
  border-radius: 4px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.selection-info {
  display: flex;
  gap: 20px;
  color: #606266;
  font-size: 14px;
}

.selected-node,
.selected-count {
  color: #409eff;
}

/* 表格容器 */
.table-container {
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #e4e7ed;
}

.table-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: bold;
  color: #303133;
}

.table-info {
  color: #909399;
  font-size: 14px;
}

.table-footer {
  padding: 15px 20px;
  border-top: 1px solid #e4e7ed;
  background-color: #fafafa;
}

.summary-info {
  display: flex;
  gap: 30px;
}

.summary-item {
  color: #303133;
}

/* 金额样式 */
.positive-amount {
  color: #67c23a;
  font-weight: bold;
}

.negative-amount {
  color: #f56c6c;
  font-weight: bold;
}

/* 充值缴费弹窗样式 */
.charge-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.charge-dialog {
  width: 1200px;
  max-height: 90vh;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e4e7ed;
  background-color: #fafafa;
}

.dialog-title {
  margin: 0;
  font-size: 18px;
  color: #303133;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #909399;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  color: #f56c6c;
}

.dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.charge-dialog-content {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

/* 左侧充值区域 */
.charge-section {
  flex: 1;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
}

.section-header {
  margin-bottom: 20px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  border-left: 4px solid #409eff;
  padding-left: 12px;
}

/* 账户余额显示 */
.account-balance {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid #e4e7ed;
}

.balance-display {
  text-align: center;
}

.balance-label {
  display: block;
  font-size: 14px;
  color: #606266;
  margin-bottom: 8px;
}

.balance-amount {
  margin-bottom: 8px;
}

.balance-amount .amount {
  font-size: 32px;
  font-weight: bold;
}

.balance-amount .unit {
  font-size: 16px;
  margin-left: 4px;
}

.balance-amount.negative-balance .amount,
.balance-amount.negative-balance .unit {
  color: #f56c6c;
}

.balance-note {
  font-size: 12px;
  color: #909399;
}

/* 表单容器 */
.form-container {
  background: white;
  border-radius: 8px;
  padding: 20px;
  border: 1px solid #e4e7ed;
}

.form-item {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
}

.form-label {
  width: 100px;
  font-size: 14px;
  color: #606266;
  line-height: 32px;
  flex-shrink: 0;
}

.form-input,
.form-textarea {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: #409eff;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.amount-chinese {
  line-height: 32px;
  color: #909399;
  font-size: 14px;
}

/* 单选按钮组 */
.payment-type-group {
  display: flex;
  gap: 20px;
}

.radio-item {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
}

.radio-item input[type="radio"] {
  margin-right: 6px;
}

.radio-text {
  color: #606266;
}

/* 充值按钮 */
.charge-btn {
  background-color: #409eff;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.charge-btn:hover:not(:disabled) {
  background-color: #66b1ff;
}

.charge-btn:disabled {
  background-color: #c0c4cc;
  cursor: not-allowed;
}

/* 右侧缴费详情区域 */
.detail-section {
  flex: 1;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
}

.detail-time {
  font-size: 12px;
  color: #909399;
  margin-top: 8px;
}

.detail-table-container {
  background: white;
  border-radius: 8px;
  border: 1px solid #e4e7ed;
  overflow: hidden;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.detail-table th,
.detail-table td {
  border: 1px solid #e4e7ed;
  padding: 8px;
  text-align: center;
}

.detail-table th {
  background-color: #f5f7fa;
  color: #606266;
  font-weight: 600;
}

.detail-table tbody tr:hover {
  background-color: #f5f7fa;
}

.status-failed {
  color: #f56c6c;
  font-size: 12px;
}

/* 缴费记录区域 */
.charge-records {
  border-top: 1px solid #e4e7ed;
  padding-top: 24px;
}

.records-header {
  margin-bottom: 16px;
}

.records-title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  border-left: 4px solid #409eff;
  padding-left: 12px;
}

.records-table-container {
  background: white;
  border-radius: 8px;
  border: 1px solid #e4e7ed;
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.records-table th,
.records-table td {
  border: 1px solid #e4e7ed;
  padding: 8px;
  text-align: center;
}

.records-table th {
  background-color: #f5f7fa;
  color: #606266;
  font-weight: 600;
  position: sticky;
  top: 0;
}

.records-table tbody tr:hover {
  background-color: #f5f7fa;
}

.success-tag {
  color: #67c23a;
  font-size: 12px;
}

.print-btn {
  background-color: #409eff;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.print-btn:hover {
  background-color: #66b1ff;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .charge-dialog {
    width: 95%;
    margin: 20px;
  }
  
  .charge-dialog-content {
    flex-direction: column;
  }
}

@media (max-width: 768px) {
  .charge-billing-container {
    flex-direction: column;
  }
  
  .left-tree-panel {
    width: 100%;
    height: 200px;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .filter-form {
    flex-direction: column;
  }
  
  .filter-input,
  .filter-select {
    width: 100%;
  }
}
</style>

